﻿using System;

namespace Program11
{
    class Program
    {
        static void Main(string[] args)
        {

            Console.WriteLine("1-5的乘积为{0}", GetMultiply(5));
            Console.WriteLine("1-5的乘积为{0}", GetMultiply2(5));
        }
        //递归
        public static long GetMultiply(int n)
        {
            if (n == 1)
                return 1;
            long temp = GetMultiply(n - 1);
            return temp * n;
        }
        //非递归
        public static long GetMultiply2(int n)
        {
            var result = 1;
            for (var i = 1; i <= n; i++)
                result = result * i;
            return result;
        }

    }
    }


